#region Summary

// 
// Owner : JackieHan 
// 
// Solution : Skomart.Spider 
// 
// Project : Jackie.Utility
// 
// File : PropertyConfig.cs
// 
// CopyRight : Copyright © 2010-2011 Skomart Corporation, All Rights Reserved 
// 
// Summary : 属性配置信息
// 
// History : 
//			2010-10-09 10:35:13	    Create 
// 

#endregion

#region Using

using System;
using System.Collections.Generic;
using System.Xml;
using Jackie.Utility.CustomException;

#endregion

namespace Jackie.Utility.BvConversion
{
    /// <summary> 
    /// 属性配置信息
    /// </summary>
    public class PropertyConfig
    {
        private const string NodeName = "property";
        private const string BusinessPropertyAttr = "businessProperty";
        private const string ViewPropertyAttr = "viewProperty";
        private const string IsSubKeyAttr = "isSubKey";
        public const string IsKeyAttr = "isKey";

        public PropertyConfig()
        {

        }

        public PropertyConfig(XmlNode node)
        {
            if (node.Name != NodeName)
                throw new XmlNodeErrorException(node.Name, NodeName);
            if (node.Attributes[BusinessPropertyAttr] == null)
                throw new XmlAttributeNotFoundException(BusinessPropertyAttr);
            if (node.Attributes[ViewPropertyAttr] == null)
                throw new XmlAttributeNotFoundException(BusinessPropertyAttr);

            this.BusinessProperty = node.Attributes[BusinessPropertyAttr].Value;
            this.ViewProperty = node.Attributes[ViewPropertyAttr].Value;
            if (node.Attributes[IsSubKeyAttr] != null)
                this.IsSubKey = Boolean.Parse(node.Attributes[IsSubKeyAttr].Value);
            if (node.Attributes[IsKeyAttr] != null)
                this.IsKey = Boolean.Parse(node.Attributes[IsKeyAttr].Value);
        }

        public string BusinessProperty { get;set; }
        public string ViewProperty { get; set; }
        public bool IsSubKey { get; set; }
        public bool IsKey { get; set; }
    }
}